
<%@ page import="duylinh.SanPham" %>
<!doctype html>
<html>
	<head>
		<meta name="layout" content="main">
		<g:set var="entityName" value="${message(code: 'sanPham.label', default: 'SanPham')}" />
		<title><g:message code="default.list.label" args="[entityName]" /></title>
	</head>
	<body>
		<a href="#list-sanPham" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
		<div class="nav" role="navigation">
			<ul>

				<li>
                    <g:link class="create" action="createEditProduct">
                        <g:message code="default.createSanPham" />
                    </g:link>
                </li>
			</ul>
		</div>
		<div id="list-sanPham" class="content scaffold-list" role="main">

            <div class="marginTopLarge marginBottomLarge">

                <div class="marginLeftStd floatL quoteBig ">
                        <g:message code="default.list.label.sanPham" default="Danh sách các sản phẩm" />

                </div>


                <div class="marginRightLarge floatR marginBottomLarge">

                    <span class="fontBold">
                        <g:message code="default.list.label.hienthi" />
                    </span>

                    <span>
                        <g:select id="loaiSanPhamBox"
                                  noSelection="${[0:message(code:'default.list.label.chonLoaiSanPham')]}"
                                  class="many-to-one"
                                  name="loaiSanPham.id"
                                  from="${duylinh.LoaiSanPham.list()}"
                                  optionKey="id"
                                  optionValue="ten"
                                  value="${loaiSanPham?.id}"
                        />

                        <g:javascript>

                            $("#loaiSanPhamBox").change(function(){
                                  var redirectUrl = CONTEXT_PATH + "/sanPham/list";
                                  redirectUrl += "?loaiSanPhamId="+$("#loaiSanPhamBox").val();
                                  redirectUrl += "&sortBy=${sortBy?sortBy:'id'}&order=${order?order:'desc'}&offset=${offset?offset:'0'}&max=${max?max:'10'}";
                                  window.location = redirectUrl;
                            });

                        </g:javascript>
                    </span>

                </div>

                <div class="clear"></div>
            </div>


			<g:if test="${flash.message}">
			<div class="message" role="status">${flash.message}</div>
			</g:if>
			<table>
				<thead>
					<tr>
                        <th>
                            <g:message code="sanPham.avatar.label" default="Anh" />
                        </th>


						<g:sortableColumn property="code" title="${message(code: 'sanPham.code.label', default: 'Code')}" />
					
						<th>
                            <g:message code="sanPham.vatLieu.label" default="Vat Lieu" />
                        </th>
					
						<th>
                            <g:message code="sanPham.congNghe.label" default="Cong Nghe" />
                        </th>

                        <th>
                            <g:message code="sanPham.thaoTac.label" default="Cong Nghe" />
                        </th>

					</tr>
				</thead>
				<tbody>
				<g:each in="${sanPhamInstanceList}" status="i" var="sanPhamInstance">
					<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
                        <td>
                            <g:link action="show" id="${sanPhamInstance.id}">
                                <img src=" ${fieldValue(bean: sanPhamInstance, field: "avatarUrl")}" width="30" height="30"   />
                            </g:link>
                        </td>
                        <td>
                            <g:link action="show" id="${sanPhamInstance.id}">
                                ${sanPhamInstance?.loaiSanPham?.ten} ${fieldValue(bean: sanPhamInstance, field: "code")}
                            </g:link>
                        </td>
					
						<td>
                            <g:link controller="vatLieu" action="show" id="${sanPhamInstance?.vatLieu?.id}">
                                ${sanPhamInstance.vatLieu?.chatLieu}  ${sanPhamInstance.vatLieu?.ten}
                            </g:link>
                        </td>
					
						<td> <g:link controller="congNghe" action="show" id="${sanPhamInstance.congNghe?.id}"> ${sanPhamInstance.congNghe?.ten} </g:link></td>
					

						<td>

                            <g:link  action="createEditProduct"  params="['sanPhamId':sanPhamInstance.id]">
                                <g:message code="default.button.edit.label"></g:message>
                            </g:link>
                        </td>
					
					</tr>
				</g:each>
				</tbody>
			</table>
			<div class="pagination">
				<g:paginate total="${sanPhamInstanceTotal}" />
			</div>
		</div>
	</body>
</html>
